package com.zhny.sensor.dao;

import com.zhny.sensor.entity.SlaughterHousePoultry;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * @Auther: zhy
 * @Date: 2019/11/23
 * @Description: 禽类品种信息更新管理
 */
public interface SlaughterHousePoultryRepository extends JpaRepository<SlaughterHousePoultry,String> {

    @Query("select u.isUpdate from SlaughterHousePoultry u where u.slaughterHouseId = ?1")
    String findIsupdateByBarcodeMachineId(String slaughterHouseId);

    @Query("select u.timeVersion from SlaughterHousePoultry u where u.slaughterHouseId = ?1")
    String findTimeVersionByBarcodeMachineId(String slaughterHouseId);

    @Modifying
    @Query("update SlaughterHousePoultry u set u.isUpdate = '0' where u.slaughterHouseId = ?1")
    int setIsupdateByBarcodeMachineId(String slaughterHouseId);

    @Modifying
    @Query("update SlaughterHousePoultry u set u.timeVersion = ?1 where u.slaughterHouseId = ?2")
    int setTimeVersionByBarcodeMachineId(String timeVersion , String slaughterHouseId);


}
